<?php
 
//////////////////////////
//traitement des actions//
//////////////////////////

if(isset($_POST["action"])&&$_POST["action"]=="init") {

	try {
		$bdd = Connect();
		$req = $bdd->exec('DELETE FROM categorie');
	}
	catch(Exception $e){
		die('Erreur : '.$e->getMessage());
	}
	$erreurs="";
	$action = $_POST["action"];
	foreach($tabNiveau as $act=>$niv){
		foreach ($niv as $n=>$etiqn){
			foreach ($tabType[$act] as $t=>$etiqt){
				$categorie = new categorie($t,$n);
				$erreurs.= $categorie->getErreurs();
					
				if($categorie->isValid()){
					//ajout dans la BD
					$categorie->ajoutBD();
				}
			}
		}
	}
	if ($erreurs==""){
		header("Location:index.php");
		exit();
	}

}


